package com.jsmile.cloud.tradecenter.api.req;

import java.util.List;

import javax.validation.constraints.Max;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull;

import com.jsmile.mall.api.to.BaseUpdateTo;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;

/**
 * @author 龚亮
 * @version 1.0
 * @desc 为了薪资破万，还是睡一会儿吧...!
 * @date 2019年04月01日 04:45:35
 */
@Data
@ApiModel
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class ReqOrderCreate extends BaseUpdateTo {

    @ApiModelProperty(value = "地址id")
    private Long addressId;
    @ApiModelProperty(value = "订单类型 1平台订单 2自营订单 3拼团订单 4秒杀订单 5.限时购")
    private Integer orderType;
    @ApiModelProperty(value = "余额支付金额")
    private Long balanceAmount;
    @ApiModelProperty(value = "是否余额支付")
    private Boolean hasBalance;
    @ApiModelProperty(value = "付款方式，1-微信小程序支付 2微信h5支付 3微信app支付 4支付宝h5支付 5支付宝APP支付 0余额支付")
    private Integer payType;
    @ApiModelProperty(value = "区域编码")
    private String areaCode;
    @ApiModelProperty(value = "优惠券id")
    private Long couponId;
    @ApiModelProperty(value = "商品明细")
    private List<OrderSku> skuList;

    @Data
    @ApiModel
    public static class OrderSku {
        @ApiModelProperty(value = "活动模板id")
        private Long templateId;
        @ApiModelProperty(value = "活动id")
        private Long activityId;
        @ApiModelProperty("skuid")
        @NotNull(message = "skuid不能为空")
        private Long skuId;
        @ApiModelProperty("spuId")
        @NotNull(message = "spuId不能为空")
        private Long spuId;
        @ApiModelProperty(value = "供应商id")
        private Long supplyId;
        @ApiModelProperty(value = "店铺id")
        private Long shopId;
        @ApiModelProperty(value = "商品数量")
        @NotNull
        @Min(1)
        @Max(100)
        private Integer skuNumber;
        @ApiModelProperty(value = "配送方式")
        private Integer deliveryType;
        @ApiModelProperty(value = "订单备注")
        private String orderRemark;

        public SplitOrder getSplitOrder() {
            return new SplitOrder(this.getShopId(), this.getSupplyId(), this.getDeliveryType());
        }
    }

}
